package com.yuexunit.finance.project.service;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.yuexunit.finance.project.entity.FreightInfoEntity;
import com.yuexunit.inject.annotation.Implements;
import com.yuexunit.persist.PersistUtil;
import com.yuexunit.persist.annotation.Transactional;

/**
*@version 创建时间：2017年3月27日 下午9:50:20
*@author wenwenlong
*类说明
*/

@Implements(FreightInfoService.class)
public class FreightInfoServiceImpl implements FreightInfoService {

	@Override
	@Transactional
	public Long createFreightInfo(FreightInfoEntity entity) {
		PersistUtil.insert(entity);
		return entity.getFreightId();
	}

	@Override
	@Transactional
	public void updateFreightInfo(FreightInfoEntity entity) {
		PersistUtil.update(entity);
	}

	@Override
	@Transactional
	public void deleteFreightInfo(Long freightId) {
		PersistUtil.delete(FreightInfoEntity.class, freightId);
	}

	@Override
	public List<FreightInfoEntity> inquireFreightInfoList(Long financeId) {
		DetachedCriteria criteria = DetachedCriteria.forClass(FreightInfoEntity.class);
		criteria.add(Restrictions.eq("financeId", financeId));
		return PersistUtil.get(criteria);
	}
}
